﻿using Dapper;
using System;
using BCEntity.Trading.SaleShoppingCart;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;

namespace BCData.Trading.SaleShoppingCart
{
    /// <summary>
    /// 销售购物车
    /// </summary>
    public interface ISaleShoppingCartData
    {
        #region  成员方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="saleShoppingCartId">销售购物车Id</param>
        Task<bool> Exists(long saleShoppingCartId);
        /// <summary>
        /// 是否存在销售商品记录
        /// </summary>
        /// <param name="saleGoodsId">销售商品Id</param>
        Task<bool> GoodsExists(long saleGoodsId);
        /// <summary>
        /// 是否存在销售商品规格记录
        /// </summary>
        /// <param name="saleGoodsNormId">销售商品规格Id</param>
        Task<bool> GoodsNormExists(long saleGoodsNormId);
        /// <summary>
        /// 增加销售购物车
        /// </summary>
        /// <param name="entity">销售购物车信息</param>
        Task<SaleShoppingCartEntity> Add(SaleShoppingCartEntity entity);
        /// <summary>
        /// 更新销售购物车
        /// </summary>
        /// <param name="entity">销售购物车信息</param>
        Task<SaleShoppingCartEntity> Update(SaleShoppingCartEntity entity);
        /// <summary>
        /// 修改购物车商品状态为已下架
        /// </summary>
        /// <param name="saleGoodsId">商品Id</param>
        /// <returns></returns>
        Task<bool> UpdateSaleGoodsDisabled(long saleGoodsId,bool disable);
        /// <summary>
        /// 修改购物车商品状态为已下架
        /// </summary>
        /// <param name="saleGoodsId">商品Id</param>
        /// <param name="saleGoodsNormId">商品款式Id</param>
        /// <returns></returns>
        Task<bool> UpdateSaleGoodsDisabled(long saleGoodsId,long saleGoodsNormId, bool disable);
        /// <summary>
        /// 修改购买数量
        /// </summary>
        /// <param name="saleShoppingCartId">销售购物车Id</param>
        /// <param name="saleCount">数量</param>
        /// <returns></returns>
        Task<bool> UpdateSaleCount(long saleShoppingCartId, int saleCount);
        /// <summary>
        /// 删除销售购物车
        /// </summary>
        /// <param name="saleShoppingCartId">销售购物车Id</param>
        Task<bool> Delete(long saleShoppingCartId);
        /// <summary>
        /// 获取销售购物车
        /// </summary>
        /// <param name="saleShoppingCartId">销售购物车Id</param>
        Task<SaleShoppingCartEntity> GetEntity(long saleShoppingCartId);
        /// <summary>
        /// 获取销售购物车列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        Task<IEnumerable<SaleShoppingCartEntity>> GetList(long userId);
        /// <summary>
        /// 获取销售购物车商品数量
        /// </summary>
        /// <param name="userId">用户Id</param>
        Task<int> Count(long userId);
        /// <summary>
        /// 获取销售购物车分页列表
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        Task<(IEnumerable<SaleShoppingCartEntity>, int)> Query(long userId, DateTime? start, DateTime? end, string sortName, bool? ascending, int pageIndex, int pageSize);
        #endregion  成员方法
        /// <summary>
        /// 合计销售商品金额
        /// </summary>
        /// <param name="ids">购物车Id</param>
        /// <returns></returns>
        Task<decimal> SumSaleGoodsAmount(List<long> ids);
    }


}